<template>
  <div class="categories">
    <template v-for="item in categories" :key="item.id">
      <div class="item">
        <img :src="item.pictureUrl" alt="">
        <span>{{item.title}}</span>
      </div>
    </template>
  </div>
</template>

<script setup>
import useHomeStore from '@/stores/modules/home';
import { storeToRefs } from 'pinia';

const homeStore = useHomeStore()
homeStore.fetchCategories()
const { categories } = storeToRefs(homeStore)
</script>

<style lang="less" scoped>
.categories {
  display: flex;
  overflow-x: auto; //溢出自适应
  margin: 0 22px;
  &::-webkit-scrollbar {
    //隐藏滚动条
    display: none;
  }
  .item {
    width: 70px;
    display: flex;
    text-align: center;
    flex-shrink: 0; //设定了固定宽度后自适应
    flex-direction: column;
    img {
      margin: auto;
      height: 32px;
      width: 32px;
    }
    span {
      font-size: 12px;
      margin-top: 3px;
    }
  }
}
</style>